#include "query_handler.h"
#include "../m_tree/mTree.h"
#include "../metric/xyz.h"
#include <stdlib.h>
int main() {
  
  struct xyz_int origin = {0,0,0};
  struct knn_state * s = knn_state_alloc(5, &origin, (double(*)(const void*,const void*))&xyz_int_distance, sizeof(struct xyz_int));
   
  struct xyz_int * objs = malloc(6000000 * sizeof(struct xyz_int));

  int i;

  for(i = 0; i < 6000000; i++) {
    objs[i].x = (5000.0*rand()/(RAND_MAX+1.0));
    objs[i].y = (5000.0*rand()/(RAND_MAX+1.0));
    objs[i].z = (5000.0*rand()/(RAND_MAX+1.0));
    //    objs[i].i = (5000.0*rand()/(RAND_MAX+1.0));
  }

  for(i = 0; i < 6000000; i++) {
    //    printf("Adding: ");
    //    xyzi_print(&objs[i],0);
    knn(&objs[i], s);
    //    knn_state_print(s, (void(*)(void*, void*))&xyzi_print);
  }
  knn_state_print(s, (void(*)(void*, void*))&xyz_int_print);
  knn_state_free(s);
  return 0;

}
